#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
int main()
{
	int a;
	int b;
	cin >> a >> b;
	int n;
	cin >> n;
	int a1, a2, b1, b2;
	int x = 0, y = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a1 >> a2 >> b1 >> b2;
		if (a2 == b2)
		{
			continue;
		}
		if (a2 == a1 + b1)
		{
			x++;
		}
		if (b2 == a1 + b1)
		{
			y++;
		}
		if (x > a)
		{
			cout << 'A' << endl << y << endl;
			break;
		}
		if (y > b)
		{
			cout << 'B' << endl << x << endl;
		}
	}
	return 0;
}